<template>
  <div>
    <el-table
      :data="tableData"
      border
      style="width: 100%">
        <el-table-column
          fixed
          prop="username"
          label="用户名"
          width="150">
        </el-table-column>
        <el-table-column
          prop="created"
          label="创建日期"
          width="120">
        </el-table-column>
        <el-table-column
          prop="email"
          label="email"
          width="120">
        </el-table-column>
        <el-table-column
          prop="password"
          label="密码"
          width="120">
        </el-table-column>
        <el-table-column
          fixed="right"
          label="操作"
          width="100">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
          </template>
        </el-table-column>
    </el-table>

<!--      <el-pagination-->
<!--        :page-size="2"-->
<!--        :pager-count="10"-->
<!--        layout="prev, pager, next"-->
<!--        :total="total"-->
<!--      @current-change="page">-->
<!--      </el-pagination>-->
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage1"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="10"
        layout="total, sizes, prev, pager, next, jumper"
        :total="100">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    handleClick(row) {
      console.log(row);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(currentPage) {
      const _this=this
      axios.get('http://localhost:8880/index/'+currentPage+'/3').then(function (resp){
        _this.tableData =resp.data.content
        _this.total=resp.data.totalElements
        // _this.total=resp.data.totalElements
        }
      )
    }
  },
  data() {
    return {
      total:null,
      currentPage1: 1,
        currentPage2: 5,
        currentPage3: 5,
        currentPage4: 1,
      tableData: null,

    }
  }
}
</script>
